//重新修改的画图js,加载本js之前先加载jsDraw2D.js文件
function drawCanven(mouseX, mouseY, flag) {
		//8：得到画板对象
		var canvasDiv = document.getElementById("canvas");
		//9：创建一个新div
		gr = new jsGraphics(canvasDiv);
		var penWidth;
		var col;
		var pen;
		//var d1, d2;
		setPenColor(true);
		var point;
		//10：坐标div
		var pointDiv;
		//11：当前鼠标坐标
		var mouseX = mouseX;
		var mouseY = mouseY;
		//12：当前坐标类型
		var flag = flag;
		//13：判断当前是否是IE
		var ie = false;
		if (document.all)
			ie = true;
		if (!ie) {
			//canvasDiv.captureEvents(Event.MOUSEMOVE)
			//canvasDiv.captureEvents(Event.CLICK)
		}
		//14：现在从数据库中取的坐标已经是做好处理的了
		//15：直接进行画点操作
		drawPoint();
		function setPenColor(noAlert) {
			col = new jsColor("blue");
			penWidth = '2';
			if (!isNaN(penWidth))
				pen = new jsPen(col, penWidth);
			else
				pen = new jsPen(col, 1);
			return true;
		}
		//16：进行画点
		function drawPoint() {
			//17：如果有画点div移除div
			try {
				if (pointDiv)
					canvasDiv.removeChild(pointDiv);
			} catch (e) {
			}
			//18：得到当前坐标div 大小
			pointDiv = gr.fillRectangle(new jsColor("green"), new jsPoint(
					mouseX-3, mouseY-3), 6, 6);
			//19：得到当前坐标点位置
			point = new jsPoint(mouseX, mouseY);
			//得到当前坐标类型
			var flagtemp = flag;
			if (flagtemp == 1) {
				//20：进行画圆
				drawCircle();
			}
			if (flagtemp == 2) {
				//21：画方形
				drawRectangle();
			}
			if (flagtemp == 3) {
				//画三角形
				drawTrigon();
			}
			// 			txt.value = point.x + "," + point.y;
		}
		function ShowPoints() {
			txt.value = "";
			for ( var i = 0; i < points.length; i++) {
				txt.value = txt.value + "new jsPoint(" + points[i].x + ","
						+ points[i].y + "),";
			}
		}
		//22：开始画圆
		function drawCircle() {
			var radius = '10';
			if (!setPenColor())
				return;
			gr.drawCircle(pen, point, radius);
			drawText();

		}
		function removpoint() {
			var length = $("#canvas").children().size();
			$("#canvas div:eq(" + length + ")").remove();
		}
		//画矩形
		function drawRectangle() {
			//矩形的1/2宽高
			var len = 8;
			var tempX = parseInt(mouseX);
			var tempY = parseInt(mouseY);
			//矩形四个顶点
			var x1 = tempX-len;
			var y1 = tempY-len;
			var x2 = tempX+len;
			var y2 = tempY-len;
			var x3 = tempX+len;
			var y3 = tempY+len;
			var x4 = tempX-len;
			var y4 = tempY+len;
			gr.drawPolygon(pen, new Array(new jsPoint(x1,y1),new jsPoint(x2,y2),new jsPoint(x3,y3),new jsPoint(x4,y4)));
			drawText();
		}
		
		//画三角形
		function drawTrigon(){
			if (!setPenColor())
				return;
			var tempX =  parseInt(mouseX);
			var tempY = parseInt(mouseY);
			//三角形三个顶点
			var x1 = tempX;
			var y1 = tempY-8;
			var x2 = tempX+10;
			var y2 = tempY+8;
			var x3 = tempX-10;
			var y3 = tempY+8;
			gr.drawPolygon(pen, new Array(new jsPoint(x1,y1),new jsPoint(x2,y2),new jsPoint(x3,y3)));
			drawText();
		}
		//24：输入文字
		function drawText() {
			var font = 10;
			var color = "#DC143C";
			var width = 10;
			var text = msg;
			if (!text || !point)
				return false;
			if (width != null)
				width = Math.round(width) + "px";
			var textDiv = canvasDiv.appendChild(document.createElement("div"));
			textDiv.style.position = "absolute";
			//为了使文本一直处于图形中心做适当调整
			var tempx = phPoint.x;
			if(text>9){
				tempx=tempx-3;		
			}
			var tempy = phPoint.y -3;
			textDiv.style.left = tempx + "px";
			textDiv.style.top = tempy + "px";
			if (color)
				textDiv.style.color = color;
			if (font) {
				if (font.family)
					textDiv.style.fontFamily = font.family;
				textDiv.style.fontWeight = 'bold';
				if (font.size)
					textDiv.style.fontSize = font.size;
				if (font.style)
					textDiv.style.fontStyle = font.style;
				if (font.variant)
					textDiv.style.fontVariant = font.variant;
			}
			if (width)
				textDiv.style.width = width;
			textDiv.innerHTML = text;
			return textDiv;
		}
	}